import {Injectable} from "@angular/core";
import {HttpClient} from "@angular/common/http";

@Injectable()
export class KnowledgeService{
  constructor(private http:HttpClient){

  }

  knowledge(id):Promise<any>{
    return this.http.get<any>(`http://www.defangit.com:30002/api/knowledge/${id}`)
      .toPromise()
      .then(res=>res[0])
  }

  addDetailForSubject(detail,knowledge:number|string){
    if(!detail) return;
    detail.knowledgeId=knowledge;
    return this.http.post(`http://www.defangit.com:30002/api/details`,detail)
      .toPromise()
      .then(res=>console.log(res));
  }
}
